package homework3;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.Map;
import java.util.Scanner;

//Student类     学生类
//属性：姓名 一张考卷  一张答卷   
//方法：void startExam();//开始考试
//      int getScore();//求出得分
public class Student {
	private String name;
	private Paper paper;
	private AnswerSheet answerSheet;
	
	public void startExam(){
		Scanner scanner = new Scanner(System.in);
		Map<String, Question> questions = paper.getPaper();
		Iterator<Question> iterator = questions.values().iterator();
		while(iterator.hasNext()){
			Question question = iterator.next();
			System.out.println(question.toString());
			System.out.println("Input your answer");
			String str = scanner.nextLine();
			answerSheet.getAnswer().put(question.getId(), str);
		}
	}
	
	public int getScore(){
		int sum=0;
		Iterator<Question> iterator = paper.getPaper().values().iterator();
		while(iterator.hasNext()){
			Question question = iterator.next();
			if(question.getRight().equals(answerSheet.getAnswer().get(question.getId()))){
				sum+=question.getScore();
			}
		}
		return sum;
	}
}
